package marsrovers;

import java.util.List;

public class Rover {
	
	private RoverPosition roverPosition;
	private List<Instruction> instructions;
	
	public Rover(RoverPosition roverPosition, List<Instruction> instructions) {
		this.roverPosition = roverPosition;
		this.instructions = instructions;
	}
	
	public RoverPosition computeFinalPosition() {
		for (Instruction instruction : instructions) {
			roverPosition.update(instruction);
		}
		
		return roverPosition;
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		
		sb.append(roverPosition.toString());
		sb.append("\n");
		for (Instruction i : instructions) {
			sb.append(i.toString());
		}
		sb.append("\n");
		return sb.toString();
	}

	public RoverPosition getPosition() {
		return roverPosition;
	}


}
